/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jsalon.enumtype;

/**
 *
 * @author Java
 */
public enum Gender {
    man(1){
        @Override
        public String caption() {
            return "Man";
        }
    },
    woman(2){
        @Override
        public String caption() {
            return "Woman";
        }
    };
    
    private int value;
    public abstract String caption();
    
    private Gender() {
        this.value = 1;
    }
    
    private Gender(int value) {
        this.value = value;
    }
    public int getVal(){
        return this.value;
    }
    
    public static Gender fromValue(int value) {  
        for (Gender my: Gender.values()) {  
            if (my.value == value) {  
                return my;  
            }  
        }  
        return null;  
    }  
    
}
